<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>商品描述配置管理</title>
    <%@ include file="/view/common/tags.jsp"%>
</head>
<body>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-body">
                    <div class="panel panel-default">
                        <div class="panel-body" style="padding-bottom:5px;">
                            <form class="form-horizontal" action="" method="post" id="dataForm">
                                <div class="searchMenu">
                                    <div>
                                        <label>游戏名称：</label>
                                        <sk:select cssClass="form-control select" id="gameId" name="wm[GAME_ID]" value="${page.wm.GAME_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseGame/gameSelect?wm[DEL_FLAG]=1" onchange="TagUtil.fillOptions('gameId');changeGameQuerySmall(this.value)">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>商品小类：</label>
                                        <sk:select cssClass="form-control select" id="goodsSmallId" name="wm[GOODS_SMALL_ID]" value="${page.wm.GOODS_SMALL_ID}">
                                            <option id="smallTypeEle" value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>交易类型：</label>
                                        <sk:select cssClass="form-control select" id="tradeId" name="wm[TRADE_ID]" value="${page.wm.TRADE_ID}" parentCascadedSelect="gameId" parentParamName="gameId" requiredInit="true" ajaxURL="${tradeV1}/tradeState/gameTradeTypeDictList">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div style="float:right;">
                                        <button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                        <sk:button type="button"  rightKey="20170816153238"  _class="btn btn-success btn-sm"  onclick="add()"><span class='glyphicon glyphicon-plus'></span>添&nbsp;加</sk:button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                        <thead>
                        <tr>
                            <th data-field="index" data-align="center" data-formatter="indexFormatter" data-sortable="false">序号</th>
                            <th data-field="gameName" data-align="center" data-sortable="true">游戏名称</th>
                            <th data-field="goodsSmallName" data-align="center" data-sortable="true">商品小类名称</th>
                            <th data-field="tradeName" data-align="center" data-sortable="true">交易类型名称</th>
                            <th data-field="content" data-align="center" data-sortable="true">内容</th>
                            <th data-field="deleteButton" data-align="center" data-formatter="buttonFormatter" data-sortable="false">操作</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<%@ include file="/view/common/footer.jsp"%>
</body>
<script>
    // 提示信息
    var msgg='<%=request.getAttribute("msg")%>';
    if (msgg && msgg!=null && msgg!='null') {
        layer.msg(msgg);
    }

    function buttonFormatter(value, row, index) {
        var caozuo1 = "<button id='btn_edit' type='button' onclick='_update("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修 改</button>";
        //var caozuo2 = "<button id='btn_edit' type='button' onclick='deletePublishNum("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-remove'></span>&nbsp;删&nbsp;除&nbsp;</button>";
        return caozuo1;
    }

    // 加载table 数据
    $(function(){
        $("#dataTable").bootstrapTable({
            url: "${tradeV1}/tradeBasePublishGoodsDesConfig/getPublishGoodsDesConfigList",
            method:"get",
            contentType: "application/x-www-form-urlencoded",
            pagination:true,
            sidePagination:"server",
            queryParams: function(params) {
                return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
            }
        });
    })

    var tableIndex = 0;
    // 弹出添加的窗口
    function add(){
        tableIndex = layer.open({
            type: 2,
            title: "添加商品描述配置",
            closeBtn: 1,
            shadeClose: true,
            area: ['650px', '400px'],
            content: '${sysManagerV1}/basePublishGoodsDesc/toAdd?rowId=0',
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
    // 弹出添加的窗口      修改功能
    function _update(rowId){
        tableIndex = layer.open({
            type: 2,
            title: "修改商品描述配置",
            closeBtn: 1,
            shadeClose: true,
            area: ['650px', '400px'],
            content: '${sysManagerV1}/basePublishGoodsDesc/toAdd?rowId='+rowId,
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }

    //查询
    function findData(){
        $("#dataTable").bootstrapTable("refresh",{} );
    }

    /*bootstrap table点击行事件*/
    $(function(){
        $("body").on("click","table>tbody>tr",function(){
            $(this).css("background","#e1ecf1").siblings().css("background","");
        });
    });

    //下拉列表显示(根据游戏查商品小类)
    function changeGameQuerySmall(gameId) {
        $("#smallTypeEle").siblings().remove();
        if (!CheckUtil.isNotNull(gameId+"")) {
            return false;
        }
        $.ajax({
            type: "post",
            url: "${userInfoV1}/gameGoodsType/smallTypeSelect",
            data:{"wm[GAME_ID]":gameId,"token":sessionStorage.getItem("token")},
            dataType:"json",
            async:false,
            success: function(data) {
                if (data.length<=0) {
                    return;
                }
                var _html = "";
                for (var i=0; i<data.length; i++) {
                    _html += "<option value= '"+data[i].value+"'>"+data[i].label+"</option>";
                }
                $("#smallTypeEle").siblings().remove();
                $("#smallTypeEle").after(_html);
            }
        });
    }
</script>
</html>